package com.tbit.main.controller;

import com.tbit.main.common.JsonResult;
import com.tbit.main.pojo.VO.*;
import com.tbit.main.service.UpKeepLogService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author yao
 * @since 2025/1/23 10:05
 */
@RestController
@RequestMapping("/upKeepLog")
public class UpKeepLogController {

    @Resource
    private UpKeepLogService upKeepLogService;

    @RequestMapping("/getList")
    public JsonResult<List<UpKeepLogRespVO>> getList(UpKeepLogQueryReqVO reqVO) {

        List<UpKeepLogRespVO> list = upKeepLogService.getList(reqVO);

        return JsonResult.succ(list);
    }

    @RequestMapping("/getCountList")
    public JsonResult<List<UpKeepLogRespVO>> getCountList(UpKeepLogQueryReqVO reqVO) {

        List<UpKeepLogRespVO> list = upKeepLogService.getCountList(reqVO);

        return JsonResult.succ(list);
    }

    @RequestMapping("/get")
    public JsonResult<UpKeepLogRespVO> getById(Integer id) {

        UpKeepLogRespVO upKeepLog = upKeepLogService.getById(id);

        return JsonResult.succ(upKeepLog);
    }

    @GetMapping("/getLastUpKeep")
    public JsonResult<UpKeepLogRespVO> getLastUpKeep(UpKeepLogQueryReqVO reqVO) {
        return JsonResult.succ(upKeepLogService.getLastUpKeepLog(reqVO.getUserCode()));
    }

    @PostMapping("/update")
    public JsonResult<Object> update(UpKeepLogReqVO reqVO) {

        upKeepLogService.update(reqVO);

        return JsonResult.succ();
    }

}
